{extend name="template/base" /}
{block name="content"}
<div class="page-container">
    {include file="form" /}
    <div class="cl pd-5 bg-1 bk-gray">
        <span class="l">
            {tp:menu menu="add,forbid,resume,delete,recyclebin" /}
             <a class="btn btn-primary radius mr-5" id="multi_apply_settlement" onclick="layer_open('司机类型管理','/admin/driver/driver_type/id/{$vo.id}.html')">司机类型</a>
        </span>
        <span class="r pt-5 pr-5">
            共有数据 ：<strong>{$count ?? '0'}</strong> 条
        </span>
    </div>
    <?php use think\Db;?>
    <table class="table table-border table-bordered table-hover table-bg mt-20">
        {php} $public_path = ROOT_PATH."public";{/php}
        <thead>
        <tr class="text-c">
            {include file="th" /}
            <th width="70">通过</th>
            <th width="70">是否已审核</th>
            <th width="70">操作</th>
        </tr>
        </thead>
        <tbody>
        {volist name="list" id="vo"}
        <tr class="text-c">
            {include file="td" /}
            <td class="f-14">
            {if empty($vo['isagree'])}
                未同意
                {else /}
                已同意
            {/if}
            </td>
            <td class="f-14">
                {if empty($vo['ischeck'])}
                未审核
                {else /}
                已审核
                {/if}
            </td>
            <td class="f-14">

                <a title="添加司机标签" href="javascript:;" onclick="layer_open('添加司机标签','/admin/driver/add_tag/id/{$vo.id}.html')" class="label label-warning radius" >添加标签</a>
                &nbsp;&nbsp;
                {switch name="vo.check_status"}
                {case value="notapply"}
                    <a href="javascript:;" onclick="apply('/admin/driver/apply/user_id/{$vo.user_id}')" class="label label-warning radius" title="申请">申请</a>
                {/case}
                {case value="applying"}
                    <a title="审核" href="javascript:;" onclick="layer_open('审核','/admin/driver/check_info/id/{$vo.id}.html')" class="label label-warning radius" >审核详细</a>
                    <a href="javascript:;" onclick="agree('/admin/driver/agree/user_id/{$vo.user_id}')" class="label label-warning radius" title="通过">通过</a>
                    <a href="javascript:;" onclick="reject('/admin/driver/reject/user_id/{$vo.user_id}')" class="label label-warning radius" title="不通过">不通过</a>
                {/case}
                {case value="checked"}

                <a href="javascript:;" onclick="apply('/admin/driver/apply/user_id/{$vo.user_id}')" class="label label-warning radius" title="重新申请">重新申请</a>
                <a href="javascript:;" onclick="reject('/admin/driver/reject/user_id/{$vo.user_id}')" class="label label-warning radius" title="不通过">不通过</a>
                {/case}
                {default /}

                {/switch}

                {$vo.status|show_status=$vo.id}
                {tp:menu menu='sedit' /}
                {tp:menu menu='sdelete' /}
            </td>
        </tr>
        {/volist}
        </tbody>
    </table>
    <div class="page-bootstrap">{$page ?? ''}</div>
</div>
<script>

    function driverInfo(id) {
        var url = '/admin/driver/details';
        if (!id){
            layer.msg('缺少必要的参数');
        }
        $.ajax({
            type: 'get',
            url: url,
            data:{ id: id },
            success: function (data) {
                if (data.code == 1){
                    layer.msg(data.msg)
                    return false
                }else{
                    layer_open('详细资料','/admin/driver/details/id/'+id,{w:'1300px',h:'750px'})
                }
            }
        })
    }
    function reject(url) {
        $.ajax({
            type: 'POST',
            url: url,
            data: null,
            success: function (re){
                if(re.msg) {
                    layer.msg(re.msg, {
                        time: 2000, //2s后自动关闭
                        btn: ['知道了']
                    }, function () {
                        location.reload()
                    });
                }else{
                layer_open('不通过','/admin/pub/role/id/1')
                }
            },
        });
    }

    function apply(url) {
        $.ajax({
            type: 'POST',
            url: url,
            data: null,
            success: function (re){
                if(re.msg) {
                    layer.msg(re.msg, {
                        time: 2000, //2s后自动关闭
                        btn: ['知道了']
                    }, function () {
                        location.reload()
                    });
                }else{
                layer_open('申请','/admin/pub/role/id/1')
                }
            },
        });
    }
    function agree(url) {
        $.ajax({
            type: 'POST',
            url: url,
            data: null,
            success: function (re){
                if(re.msg) {
                    layer.msg(re.msg, {
                        time: 2000, //2s后自动关闭
                        btn: ['知道了']
                    }, function () {
                        location.reload()
                    });
                }else{
                layer_open('通过','/admin/pub/id/1')
                }
            },
        });
    }
    $(function () {
        var tag = $("#tag").select2({
            language: "zh-CN", //设置 提示语言
            width: "100%", //设置下拉框的宽度
            theme: "classic"
        });
        {notempty name = "Request.param.tag"}
        tag.val("{$Request.param.tag}").trigger("change");
        {/notempty}
            var driver_rank_id = $("#driver_rank_id").select2({
                language: "zh-CN", //设置 提示语言
                width: "100%", //设置下拉框的宽度
                theme: "classic"
            });
            {notempty name = "Request.param.driver_rank_id"}
            driver_rank_id.val("{$Request.param.driver_rank_id}").trigger("change");
            {/notempty}
    })
</script>
{/block}

